package models

import (
	"github.com/beego/beego/v2/client/orm"
)

type Sub_region_configuration struct {
	RegionId     int
	MainRegionId int
	RegionName   string `orm:"size(128)"`
	RegionCode   string `orm:"size(128)"`
	FlagImage    string `orm:"size(128)"`
}

func init() {
	orm.RegisterModel(new(Sub_region_configuration))
}

func GetSub_region_configurationByCode(code string) (v *Sub_region_configuration, err error) {
	o := orm.NewOrm()
	v = &Sub_region_configuration{}
	if err = o.QueryTable(new(Sub_region_configuration)).Filter("region_code", code).RelatedSel().One(v); err == nil {
		return v, nil
	}
	return v, err
}

func GetSub_region_configurationByRegionId(regionId int) (v *Sub_region_configuration, err error) {
	o := orm.NewOrm()
	v = &Sub_region_configuration{}
	if err = o.QueryTable(new(Sub_region_configuration)).Filter("region_id", regionId).RelatedSel().One(v); err == nil {
		return v, nil
	}
	return v, err
}
